package guda.talk.biz.common.util;

import java.math.BigDecimal;

/**
 * Created by well on 15/9/9.
 */
public class FloatUtil {

    /**
     * 千克字符串  转换成克
     * @param str
     * @return
     */
    public static Long convert2gram(String str) {
        if (com.alibaba.citrus.util.StringUtil.isEmpty(str)){
            return null;
        }
        BigDecimal bigDecimal = new BigDecimal(str);
        return bigDecimal.multiply(new BigDecimal(1000)).longValue();
    }

    public static String format2kilogram(Long weight) {
        if (weight == null){
            return null;
        }
        BigDecimal bigDecimal = new BigDecimal(weight);
        return bigDecimal.divide(new BigDecimal(1000)).toPlainString();
    }

    public static void main(String[] args){
        System.out.println(format2kilogram(12345L));
    }


}
